package org.kl.bf.entity.basic;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.kl.bf.entity.AuditableEntity;
import org.kl.bf.entity.Excel;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "basic_function")
public class Function extends AuditableEntity {
	private static final long serialVersionUID = 1L;
	@Excel(exportName = "功能编号")
	private String functionNo;
	@Excel(exportName = "功能名称")
	private String functionName;
	@Excel(exportName = "其他权限")
	private String otherRights;
	@Excel(exportName = "所属菜单", exportProperty = "menuName")
	private Menu menu;
	@SuppressWarnings("unused")
	private String menuName;

	// private Menu menu;

	@Transient
	public String getMenuName() {
		if (menu != null) {
			return menu.getMenuName();
		}
		return "";
	}

	@JsonIgnore
	@ManyToOne
	@JoinColumn(name = "MENU_ID")
	public Menu getMenu() {
		return menu;
	}

	public void setMenu(Menu menu) {
		this.menu = menu;
	}

	public String getOtherRights() {
		return otherRights;
	}

	public void setOtherRights(String otherRights) {
		this.otherRights = otherRights;
	}

	public String getFunctionNo() {
		return functionNo;
	}

	public void setFunctionNo(String functionNo) {
		this.functionNo = functionNo;
	}

	public String getFunctionName() {
		return functionName;
	}

	public void setFunctionName(String functionName) {
		this.functionName = functionName;
	}

	/*
	 * @Transient public Menu getMenu() { return menu; }
	 * 
	 * public void setMenu(Menu menu) { this.menu = menu; }
	 */

}